package tables

import (
	"fmt"
	"peilian-api/app/global/errors"
	"peilian-api/app/global/variable"
)

const (
	Tconvert = "convert"
	Tpolar   = "polar"
	Tinit    = "init" //开场白
	Tcivil   = "civil"
	Tfinish  = "finish"
	Tdefault = "default"
	Tspecial = "special" // 专项练习聆听视频
	Trealism = "realism" // 拟真练习聆听视频
)

type MarginVideo struct { //开始结束视频
	Model
	Text    string `json:"text"`
	Video   string `json:"video" gorm:"type:varchar(255);not null"`
	PcVideo string `json:"pc_video" gorm:"type:varchar(255);not null;comment:pc端视频url"`
	Type    string `json:"type" gorm:"type:varchar(20)"`
	Tag     string `json:"tag" gorm:"type:varchar(10)"`
}

func (m *MarginVideo) TableName() string {
	return "margin_video"
}

// 根据Typepolar视频
func (*MarginVideo) GetMerginVideoByType(typ string) ([]MarginVideo, error) {
	var Video []MarginVideo
	if err := variable.DB.MySQL.Where("type=?", typ).Find(&Video).Error; err != nil {
		return Video, fmt.Errorf(errors.DatabaseMySqlOptionFail)
	}
	return Video, nil
}
